﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Obligatorio.DataAccess;
using System.Web.UI;

/// <summary>
/// Summary description for MasterPagePresenter
/// </summary>
public class MasterPagePresenter
{
	#region Fields
	IMasterPageView _view;
	#endregion

	public MasterPagePresenter(IMasterPageView view)
	{
		this._view = view;
	}

    public void Load()
    {
        if (this._view.IsAuthenticated)
        {
            using (ObligatorioDotNetEntities data = new ObligatorioDotNetEntities())
            {
                this._view.Roles = data.Users.Where(x => x.UserName == this._view.UserName).SingleOrDefault()
                                        .Roles.Where(r => !string.IsNullOrEmpty(r.RoleModuleUrl)).ToList();


                this._view.PopulateMenu();
            }
        }
    }
}